package query

import (
	"context"

	"server_1.0/api/internal/svc"
	"server_1.0/api/internal/types"
	"server_1.0/service/question/question"

	"github.com/zeromicro/go-zero/core/logx"
)

type QueryQuestionAllLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewQueryQuestionAllLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QueryQuestionAllLogic {
	return &QueryQuestionAllLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *QueryQuestionAllLogic) QueryQuestionAll() (resp *types.PostReps, err error) {
	Resp, _ := l.svcCtx.QuestionRpc.Query(l.ctx, &question.Empty{})
	return &types.PostReps{
		Code: 200,
		Msg:  "成功",
		Data: map[string]interface{}{
			"count": Resp.Count,
			"ret":   Resp.QRs,
		},
	}, nil
}
